<?php

class Default_IndexController extends Zend_Controller_Action
{

    public function init()
    {
    	$option=array(
    			"layout" => "layout",
    			"layoutPath" => TEMPLATES_PATH."/default/"
    	);
    	$layout = Zend_Layout::startMvc($option);
    	$this->view->headLink()->appendStylesheet(TEMPLATES_URL.'/default/css/style.css');
    	$this->view->headScript()->appendFile(TEMPLATES_URL.'/default/js/jquery.min.js');
    	$this->view->headScript()->appendFile(TEMPLATES_URL.'/default/js/check.form.js');
    }

    public function indexAction()
    {
        if($this->_request->isPost())
        {
        	$userID = trim(strip_tags($this->_request->getPost("userid")));
        	$name = trim(strip_tags($this->_request->getPost("name")));
        	$phone = trim(strip_tags($this->_request->getPost("phone")));
        	$email = trim(strip_tags($this->_request->getPost("email")));
        	$model = trim(strip_tags($this->_request->getPost("model")));
        	$os = trim(strip_tags($this->_request->getPost("os")));
        	//$status = trim(strip_tags($this->_request->getPost("status")));
        	//var_dump($os);die;
        	if($userID != "" && $email !=""){
        		$mUser = new Default_Model_User();
        		
        		$mUser->userID = $userID;
        		$mUser->name = $name;
        		$mUser->phone = $phone;
        		$mUser->email = $email;
        		$mUser->model = $model;
        		$mUser->os = $os;
        		$mUser->insertUser();
        		echo "<script>alert('Them Thanh Cong!')</script>";
        	}else echo "<script>alert('Them Khong Thanh Cong!')</script>";
        	
        }
    }


}

